<template>
  <div class="module-card" :class="{ 'new-module': module.isNew }">
    <RouterLink v-if="!module.isNew" :to="module.path" class="module-link">
      <div class="module-content">
        <div class="module-icon">
          <span v-if="!module.isNew">📁</span>
          <span v-else>➕</span>
        </div>
        <div class="module-info">
          <h3 class="module-name">{{ module.name }}</h3>
          <p class="module-description">{{ module.description }}</p>
        </div>
        <div class="module-arrow">
          <span>→</span>
        </div>
      </div>
    </RouterLink>
    <div v-else class="module-content new-module-content" @click="createModule">
      <div class="module-icon">
        <span>➕</span>
      </div>
      <div class="module-info">
        <h3 class="module-name">{{ module.name }}</h3>
        <p class="module-description">{{ module.description }}</p>
      </div>
      <div class="module-arrow">
        <span>→</span>
      </div>
    </div>
  </div>
</template>

<script setup>
// defineProps and defineEmits are compiler macros and don't need to be imported in Vue 3.3+

const props = defineProps({
  module: {
    type: Object,
    required: true
  }
})

const emit = defineEmits(['create-module'])

function createModule() {
  emit('create-module', props.module)
}
</script>

<style scoped>
.module-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  border: 1px solid #e0e0e0;
}

.module-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  border-color: #42b883;
}

.module-link {
  text-decoration: none;
  display: block;
}

.module-content {
  padding: 20px;
  display: flex;
  align-items: center;
  min-height: 80px;
}

.new-module-content {
  cursor: pointer;
}

.module-icon {
  font-size: 24px;
  margin-right: 15px;
  width: 50px;
  text-align: center;
}

.module-info {
  flex: 1;
  text-align: left;
}

.module-name {
  margin: 0 0 8px 0;
  font-size: 1.1em;
  color: #333;
  font-weight: 600;
}

.module-description {
  margin: 0;
  color: #666;
  font-size: 0.9em;
  line-height: 1.4;
}

.module-arrow {
  margin-left: 15px;
  color: #999;
  font-weight: bold;
}

/* New Module Styling */
.new-module {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.new-module .module-name,
.new-module .module-description {
  color: white;
}

.new-module .module-arrow {
  color: white;
}

.new-module:hover {
  background: linear-gradient(135deg, #3c91e6 0%, #00b7ff 100%);
}

@media (max-width: 768px) {
  .module-content {
    padding: 15px;
  }

  .module-name {
    font-size: 1em;
  }

  .module-description {
    font-size: 0.8em;
  }
}
</style>